package ai.weed.qrcode.common;

import ai.weed.qrcode.common.enums.ResponseStatus;
import lombok.Data;

/**
 * description
 *
 * @author zhong.wang
 * @date 2025/10/30
 **/
@Data
public class Response<T> {
    /**
     * 状态码
     */
    private Integer code;

    /**
     *  数据
     */
    private T data;

    /**
     * 提示信息
     */
    private String message;

    /**
     * 成功响应
     * @param data
     * @return
     * @param <T>
     */
    public static <T> Response<T> success(T data) {
        Response<T> response = new Response<>();
        response.setCode(ResponseStatus.OK.getCode());
        response.setData(data);
        return response;
    }

    /**
     * 错误响应
     * @param status
     * @return
     * @param <T>
     */
    public static <T> Response<T> error(ResponseStatus status) {
        Response<T> response = new Response<>();
        response.setCode(status.getCode());
        response.setMessage(status.getMessage());
        return response;
    }
}
